/*
 * gbdt_updater.h
 *
 *  Created on: 2012-7-21
 *      Author: wanghaox
 */

#ifndef GBDT_UPDATER_H_
#define GBDT_UPDATER_H_

#include <map>
#include "gbdt.h"
#include "gbdt_tree.h"
#include "gbdt_feature.h"
#include "gbdt_param.h"

using namespace std;

class GbdtUpdater: public Updater {
public:
	bool add_data(string &line, int seq_no);
	bool iteration();

	bool init();

	bool gather_from(Message *msg);
	bool spread_to(Message *msg);
private:
	bool parse_key_value(string &feature, string &value);
	bool is_local_feature(int fid);

	void update_gradient();

private:
	map<int, GbdtFeature> _feature_map;
	GbdtTree _tree;
	GbdtParam _param;

	GBDT_SYNC_STEP _next_sync_step;
};

#endif // GBDT_UPDATER_H_
